package one.stand.controller;

import lombok.extern.slf4j.Slf4j;
import one.stand.model.ResultModel;
import one.stand.request.GoodSpecRequest;
import one.stand.request.GoodsRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 产品信息管理
 *
 * @author Administrator
 */
@RestController
@RequestMapping("/goods")
@Slf4j
public class GoodsController extends BaseController {

    /**
     * 代理产品.
     *
     * @param request
     * @return
     */
    @PostMapping("/agent")
    public ResultModel agentGoods(@RequestBody GoodsRequest request) {
        return goodsService.agentGoods(request);
    }

    /**
     * 更新产品信息.
     *
     * @param request
     * @return
     */
    @PostMapping("/updateGoods")
    public ResultModel updateGoods(@RequestBody GoodsRequest request) {
        return goodsService.updateGoods(request);
    }

    /**
     * 移动商品信息 PC端
     */
    @PostMapping("/moveGoodsInfo")
    public ResultModel<Boolean> moveGoodsInfo(@RequestBody GoodsRequest request) {
        return goodsService.moveGoodsInfo(request);
    }

    /**
     * 添加/修改商品规格信息
     */
    @PostMapping("/addGoodSpecInfo")
    public ResultModel addGoodSpecInfo(@RequestBody GoodSpecRequest request) {
        return goodsService.addGoodSpecInfo(request);
    }

    /**
     * 转移产品
     */
    @PostMapping("/transferGoods")
    public ResultModel transferGoods(@RequestBody GoodsRequest request) {
        return goodsService.transferGoods(request);
    }

    /**
     * 删除商品信息
     */
    @PostMapping("/delGoodsInfo")
    public ResultModel delGoodsInfo(@RequestBody GoodsRequest request) {
        return goodsService.delGoodsInfo(request.getGoodsId());
    }

    /**
     * 删除商品规格信息
     */
    @PostMapping("/delGoodSpecInfo")
    public ResultModel delGoodSpecInfo(@RequestBody GoodSpecRequest request) {
        return goodsService.delGoodSpecInfo(request);
    }
}
